package com.ymatou.shop.ui.adapter;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.widget.ArrayAdapter;

public class BaseAdapter<T> extends ArrayAdapter<T> {
	
	private List<T> mItems;
	private LayoutInflater mLayoutInflater;

	public BaseAdapter(Context context, List<T> items) {
		super(context, 0, items);
		setNotifyOnChange(false);
		
		mItems = items;
	}
	
	@Override
	public int getCount() {
		return mItems == null ? 0 : mItems.size();
	}
	
	public LayoutInflater getLayoutInflater() {
		synchronized (this) {
			if (mLayoutInflater == null) {
				mLayoutInflater = LayoutInflater.from(getContext());
			}
		}
		return mLayoutInflater;
	}

}
